////////////////////////////////////////////////////////////////////////////////
// $Id$
// Copyright (C) 2008
// Emory Merryman
// ree9opdz@gmail.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
////////////////////////////////////////////////////////////////////////////////

package com . linglingqi . factories ;

/**
 * Use reflection to make Input/Output streams.
 *
 * @author $Author$
 * @version $Revision$
 **/
public final class OutputStreamFactories
{
    /**
     * Embedded Copyright Notice.
     **/
    public static final java . lang . String EMBEDDED_COPYRIGHT =
        "Copyright (C) 2008, Emory Merryman, ree9opdz@gmail.com" ;

    /**
     * Hide the no-arg constructor.
     **/
    private OutputStreamFactories ( )
    {
	super ( ) ;
    }

    /**
     * Makes a FileOutputStream.
     **/
    public static final Factory0
	< java . io . ByteArrayOutputStream ,
	java . lang . RuntimeException >
	BYTEARRAYOUTPUTSTREAMFACTORY ;

    /**
     * Makes a FileOutputStream.
     **/
    public static final Factory1
	< java . io . OutputStream ,
	java . io . File ,
	java . io . IOException >
	FILEOUTPUTSTREAMFACTORY ;

    static
    {
	final java . util . logging . Logger logger =
	    java . util . logging . Logger . getLogger
	    ( OutputStreamFactories . class . toString ( ) ) ;
	final java . util . logging . Level level =
	    java . util . logging . Level . SEVERE ;
	Factory0
	    < java . io . ByteArrayOutputStream ,
	    java . lang . RuntimeException >
	    bytearrayoutputstreamfactory =
	    null ;
	try
	    {
		bytearrayoutputstreamfactory =
		    ConstructorFactories . instance
		    (
		     java . io . ByteArrayOutputStream . class ,
		     java . io . ByteArrayOutputStream . class ,
		     java . lang . RuntimeException . class
		     ) ;
	    }
	catch ( final java . lang . Exception cause )
	    {
		final java . lang . String message =
		    "The ByteArrayOutputStreamFactory did not initialize." ;
		logger . log ( level , message , cause ) ;
	    }
	finally
	    {
		BYTEARRAYOUTPUTSTREAMFACTORY = bytearrayoutputstreamfactory ;
	    }
	Factory1
	    < java . io . OutputStream ,
	    java . io . File ,
	    java . io . IOException >
	    fileoutputstreamfactory =
	    null ;
	try
	    {
		fileoutputstreamfactory =
		    ConstructorFactories . instance
		    (
		     java . io . OutputStream . class ,
		     java . io . FileOutputStream . class ,
		     java . io . File . class ,
		     java . io . IOException . class
		     ) ;
	    }
	catch ( final java . lang . Exception cause )
	    {
		final java . lang . String message =
		    "The FileOutputStreamFactory did not initialize." ;
		logger . log ( level , message , cause ) ;
	    }
	finally
	    {
		FILEOUTPUTSTREAMFACTORY = fileoutputstreamfactory ;
	    }
    }
}
